package com.statistics.servlet;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.statistics.service.BasicDataService;
import com.statistics.service.impl.BasicDataServiceImpl;
import com.statistics.vo.BasicData;

public class BasicServlet extends HttpServlet {
	private BasicDataService bds ;
	private int page = 1 ;
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		bds = new BasicDataServiceImpl() ;
		String param = req.getParameter("page") ;
		if(param != null) {
			page = Integer.parseInt(param) ;
		}

		List<BasicData> list = bds.findAllData(page) ;
		
		req.setAttribute("list", list) ;
		req.getRequestDispatcher("basicdata.jsp").forward(req, resp) ;
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException ,IOException {
		this.doGet(req, resp) ;
	};
}
